<?xml version="1.0" encoding="UTF-8"?>

<!--
    Document   : listProductFO.xsl
    Created on : February 26, 2013, 12:56 PM
    Author     : NganNLK60334
    Description:
        Purpose of transformation follows.
-->

<xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform" xmlns:fo="http://www.w3.org/1999/XSL/Format" version="1.0">
    <xsl:output method="xml"/>

    <!-- TODO customize transformation rules 
         syntax recommendation http://www.w3.org/TR/xslt 
    -->
    <xsl:template match="/">
        <fo:root xmlns:fo="http://www.w3.org/1999/XSL/Format">
            <fo:layout-master-set>
                <fo:simple-page-master master-name="Funny-portrait"
                        page-height="29.7cm" page-width="21.0cm" margin="2cm">
                    <fo:region-body/>
                </fo:simple-page-master>
            </fo:layout-master-set>

            <fo:page-sequence master-reference="Funny-portrait">
                <fo:flow flow-name="xsl-region-body">
                    <fo:block font-size="50pt" line-height="100pt" text-align="center" color="red" font-family="Arial">
                        List Products of Funny shop
                    </fo:block>

                    <fo:block>
                        <fo:table text-align="center">
                            <fo:table-column column-width="15mm"/>
                            <fo:table-column column-width="50mm"/>
                            <fo:table-column column-width="40mm"/>
                            <fo:table-column column-width="20mm"/>
                            <fo:table-column column-width="55mm"/>

                            <fo:table-body>
                                <fo:table-row>
                                    <fo:table-cell border-style="solid" color="blue">
                                        <fo:block>Product ID</fo:block>
                                    </fo:table-cell>
                                    <fo:table-cell border-style="solid" color="blue">
                                        <fo:block>Product Image</fo:block>
                                    </fo:table-cell>
                                    <fo:table-cell border-style="solid" color="blue">
                                        <fo:block>Product Name</fo:block>
                                    </fo:table-cell>
                                    <fo:table-cell border-style="solid" color="blue">
                                        <fo:block>Price</fo:block>
                                    </fo:table-cell>
                                    <fo:table-cell border-style="solid" color="blue">
                                        <fo:block>Description</fo:block>
                                    </fo:table-cell>
                                </fo:table-row>

                                <xsl:for-each select="products/product">
                                    <fo:table-row>
                                        <fo:table-cell border-style="solid">
                                            <fo:block font-family="Arial">
                                                <xsl:value-of select="productID"/>
                                            </fo:block>
                                        </fo:table-cell>
                                        <fo:table-cell border-style="solid" >
                                            <fo:block>
                                                <fo:external-graphic content-height="scale-to-fit" height="2.00in"  content-width="2.00in" src="url(http://localhost:8084/XMLProjectAssignment/Pictures/xmlImg/{productImg})"/>
                                            </fo:block>
                                        </fo:table-cell>
                                        <fo:table-cell border-style="solid">
                                            <fo:block font-family="Arial">
                                                <xsl:value-of select="productName"/>
                                            </fo:block>
                                        </fo:table-cell>
                                        <fo:table-cell border-style="solid">
                                            <fo:block font-family="Arial">
                                                <xsl:value-of select="price"/>
                                            </fo:block>
                                        </fo:table-cell>
                                        <fo:table-cell border-style="solid">
                                            <fo:block font-family="Arial">
                                                <xsl:value-of select="description"/>
                                            </fo:block>
                                        </fo:table-cell>
                                    </fo:table-row>
                                </xsl:for-each>
                            </fo:table-body>
                        </fo:table>
                    </fo:block>
                </fo:flow>
            </fo:page-sequence>
        </fo:root>
    </xsl:template>

</xsl:stylesheet>
